package com.hhs.storage.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.Result;
import com.hhs.storage.bean.YymUserYijian;
import com.hhs.storage.service.YymUserYijianService;
import jdk.nashorn.internal.runtime.logging.Logger;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yuanjun
 * @since 2020-08-15
 */
@RestController
@RequestMapping("/app/yymuseryijian")
@Slf4j
public class AppYymUserYijianController {
    @Resource
    YymUserYijianService yymUserYijianService;
    @RequestMapping(value = "getAll")
    public Map<String, Object> getAll(InputParam inputParam) {
        log.info("查询用户意见信息");
        EntityWrapper ew = new EntityWrapper<YymUserYijian>();
        ew.orderBy("create_time_",false);
        Page<YymUserYijian> result = yymUserYijianService.selectPage(new Page<YymUserYijian>(inputParam.getPage(), inputParam.getSize()),ew);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("rows", result.getRecords());
        map.put("total",result.getTotal());
        return map;
    }

    @RequestMapping(value = "saveyj")
    public Map<String, Object> saveinf(YymUserYijian yjb) {
        log.info("---add---");
        yjb.setCreateTime(new Date());
        yymUserYijianService.insert(yjb);
        return Result.sucJsonResp("已经收到您的意见，我们会尽快完善！");
    }

}

